home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2011 November
/
CHIP_2011_11.iso
/
Programy
/
Inne
/
Gry
/
Carnage_Contest
/
scripts
/
CC Original
/
weapons
/
Quake.lua
< prev
next >
Wrap
Text File
|
2009-09-16
|
2KB
|
74 lines
--------------------------------------------------------------------------------
-- Weapon Quake + Projectile Quake
-- Original Carnage Contest Weapon
-- Script by DC, September 2009, www.UnrealSoftware.de
--------------------------------------------------------------------------------
-- Setup Tables
if cc==nil then cc={} end
cc.quake={}
cc.quake.quake={}
-- Load & Prepare Ressources
cc.quake.gfx_wpn=loadgfx("weapons/quake.png") -- Weapon Image
setmidhandle(cc.quake.gfx_wpn)
cc.quake.sfx_attack=loadsfx("quake.ogg") -- quake Sound
--------------------------------------------------------------------------------
-- Weapon: Quake
--------------------------------------------------------------------------------
cc.quake.id=addweapon("cc.quake","Quake",cc.quake.gfx_wpn,0,2) -- Add Weapon (0 uses, first in round 2)
function cc.quake.draw() -- Draw
-- Do nothing
end
function cc.quake.attack(attack) -- Attack
if (weapon_shots<=0) then
if (attack==1) then
-- No more weapon switching!
useweapon(0)
weapon_shots=weapon_shots+1
-- Effect
playsound(cc.quake.sfx_attack)
id=createprojectile(cc.quake.quake.id)
projectiles[id]={}
projectiles[id].timer=50*5
-- End Turn
endturn()
end
end
end
--------------------------------------------------------------------------------
-- Projectile: Quake
--------------------------------------------------------------------------------
cc.quake.quake.id=addprojectile("cc.quake.quake") -- Add Projectile
function cc.quake.quake.draw() -- Draw
-- Do nothing
end
function cc.quake.quake.update() -- Update
id=projectileid()
-- Quake effect
quake(10)
-- Timer
projectiles[id].timer=projectiles[id].timer-1
-- Shake players
if (projectiles[id].timer%25)==0 then
players=playertable()
for i=1,#players,1 do
if getplayerhealth(players[i])>0 and getplayeraction(players[i])==0 then
math.randomseed(players[i]*512+getframe()*14189)
playerpush(players[i],math.random(-7,7),math.random(-7,-3))
end
end
end
-- End quake (free projectile)
if projectiles[id].timer<=0 then
freeprojectile(id)
end
end